package com.pretty.test.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pretty.test.controller.pets.blogcomment.vo.CommentListVO;
import com.pretty.test.entity.PetsBlogComment;
import com.pretty.test.mapper.PetsBlogCommentMapper;
import com.pretty.test.service.IPetsBlogCommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pretty.test.utils.otherutils.Func;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 博客评论服务实现类
 * @author dujianyu
 * @since 2021-04-21
 */
@Service
public class PetsBlogCommentServiceImpl extends ServiceImpl<PetsBlogCommentMapper, PetsBlogComment> implements IPetsBlogCommentService {

    @Override
    public List<CommentListVO> getCommentByBlogId(String blogId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("pbc.is_deleted",0);
        queryWrapper.eq("pbc.blog_id", Func.toLongArray(blogId)[0]);
        queryWrapper.orderByDesc("pbc.create_time");
        return baseMapper.getCommentByBlogId(queryWrapper);
    }
}
